#include "Timer_linux.hpp"
#ifdef Q_OS_LINUX
Timer::Timer()
{
    Tcl_GetTime(&start_time);
    current_time = store = last_time = start_time;
}

float Timer::absolute() {
    Tcl_GetTime(&current_time);
    store = current_time - start_time;
    return tclToS(store);
}

float Timer::delta() {
    Tcl_GetTime(&current_time);
    store = current_time - last_time;
    last_time = current_time;
    return tclToS(store);
}

void Timer::start() {
    Tcl_GetTime(&start_time);
}

Tcl_Time operator-(const Tcl_Time &l,const Tcl_Time &r) {
    Tcl_Time ret;
    ret.sec = l.sec-r.sec;
    ret.usec = l.usec-r.usec;
    return ret;
}

float tclToS(const Tcl_Time &t) {
    float r = t.sec;
    r += float(t.usec)/1000000.0f;
    return r;
}
#endif
